//BM50 两数之和 https://www.nowcoder.com/practice/20ef0972485e41019e39543e8e895b7f

class Solution {
public:
    /**
     * 
     * @param numbers int整型vector 
     * @param target int整型 
     * @return int整型vector
     */
    vector<int> twoSum(vector<int>& numbers, int target) {
        // write code here
        unordered_map<int,int> um;//值-下标
        for(int i = 0;i<numbers.size();i++)
        {
            if(um.find(target-numbers[i]) != um.end())
                return {um[target-numbers[i]],i+1};
            um.insert({numbers[i],i+1});
        }
        return {-1,-1};
    }
};



//BM52 数组中只出现一次的两个数字   https://www.nowcoder.com/practice/389fc1c3d3be4479a154f63f495abff8

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param array int整型vector 
     * @return int整型vector
     */
    vector<int> FindNumsAppearOnce(vector<int>& array) {
        // write code here
        int eor = 0;
        for(auto x:array)
            eor ^= x;
        cout << eor << endl;
        int rightOne = eor&(-eor);//得到最右边的1
        cout << rightOne<<endl;
        int ans = 0;
        eor = 0;
        for(auto x:array)
        {
            if(x & rightOne)
            {
                ans ^= x;
            }
            else
            {
                eor ^= x;
            }
        }
        if(eor>ans)  
            return {ans,eor};
        else 
            return {eor,ans};
    }
};